package com.neusoft.bigdata.hbase.util;

import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Random;

/**
 * @author lihzh
 * @date 2013-4-2 下午4:25:43
 */
public class CommonUtil {
	
	private static Random ran = new Random();

	public static final String TABLE_NAME_STATISTIC = "statistic";
	public static final String CF_NAME_STINFO = "stinfo";

	public static final String ID_PREFIX = "XXXXXXXX-XXXX-XXXX-XXXX-";
	public static final int TOTAL_RESOURCE_COUNT = 2200;
	public static final int METRIC_COUNT_ONE = 100;
	public static final int RESOURCE_COUNT_ONE = 1100;
	public static final int METRIC_COUNT_TWO = 20;
	public static final int RESOURCE_COUNT_TWO = 1100;

	public static final String METRIC_NAME_PREFIX = "metric";

	// 2011年11月1日
	public static final long STARTTIME = CommonUtil.getTime(2011, 10, 1, 0, 0);

	/**
	 * 生成Id
	 * 
	 * @param resourceCount
	 * @return
	 * @author lihzh
	 * @date 2013-3-27 下午3:27:59
	 */
	public static String createId(int num) {
		DecimalFormat format = new DecimalFormat();
		format.setMinimumIntegerDigits(12);
		format.setGroupingUsed(false);
		return format.format(num);
	}

	public static long getTime(int year, int month, int day, int hour,
			int minute) {
		Calendar calendar = Calendar.getInstance();
		calendar.set(year, month, day, hour, minute, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return calendar.getTime().getTime();
	}
	
	public static String getValue() {
		DecimalFormat format = new DecimalFormat();
		format.setMaximumFractionDigits(2);
		double value = ran.nextDouble();
		return format.format(value);
	}

}
